package com.lizhi.yun.db.sfrobot.entity;


import com.lizhi.mybatis.boot.Description;
import com.lizhi.yun.db.sfrobot.common.IllnessCauseType;
import com.lizhi.yun.db.sfrobot.common.IllnessSideType;
import com.lizhi.yun.db.sfrobot.common.IllnessStageType;
import com.lizhi.yun.db.sfrobot.common.RobotType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import javax.persistence.*;
import java.util.Date;

@Data
@ToString
@Table(name = "his_center_patient")
@Entity
@Description("患者")
public class Patient extends AbstractHisEntity {

    @Id
    @Column(length = 30)
    @Description("lid")
    public String lid;

    @Column(length = 30)
    @Description("记录id")
    public String id;

    /**
     * 用户id，一个用于id可能对应多个患者身份
     */
    @Column
    @Description("用户id")
    public String userId;

    @Column(length = 20)
    @Description("用户姓名")
    public String name;

    /**
     * 年龄（新增）
     */
    @Column
    @Description("年龄")
    public Integer age;

    @Column
    @Description("性别类型id")
    public Integer genderId;

    @Column
    @Description("性别类型名称")
    public String genderText;

    @Column
    @Description("编号")
    public String no;
    /**
     * 证件类型
     */
    @Column
    @Description("证件类型id")
    public Integer  certificateTypeId;
    /**
     * 证件类型名称
     */
    @Column(length = 20)
    @Description("证件类型名称")
    public String certificateTypeText;
    /**
     * 证件编号
     */
    @Column(length = 20)
    @Description("证件编号")
    public String certificateNo;

    /**
     * 社保证书编号
     */
    @Column(length = 20)
    @Description("社保编号")
    public String socialSecurityNo;

    /**
     * 住院号
     */
    @Column(length = 20)
    @Description("住院号")
    public String hospitalizedNo;

    @Column
    @Description("生日")
    public Date birthday;

    @Column
    @Description("手机号")
    public String phone;

    @Column(length = 50)
    @Description("地址")
    public String address;

    /**
     * 主治医师
     */
    @Column
    @Description("医师id")
    public String doctorId;

    /**
     * 病因
     */
    @Column(length = 50)
    @Description("病因")
    public Integer illnessCause;

    @Description("病因")
    @Transient
    public String illnessCauseText;

    /**
     * 生病时间
     */
    @Column
    @Description("患病时间")
    public Date illnessTime;
    /**
     * 患病侧
     * @see com.lizhi.yun.db.sfrobot.common.IllnessSideType
     */
    @Column
    @Description("患侧")
    public Integer illnessSide;

    @Description("患侧")
    @Transient
    public String illnessSideText;
    /**
     * 患病阶段
     */
    @Column
    @Description("患病阶段")
    public Integer illnessStage;

    @Description("患病阶段")
    @Transient
    public String illnessStageText;

    /**
     * 病情描述
     */
    @Column(length = 500)
    @Description("病情描述")
    public String illnessDescription;

    /**
     * 肩宽
     */
    @Column
    @Description("肩宽")
    public Float shoulderWidth;
    /**
     * 胸厚
     */
    @Column
    @Description("胸厚")
    public Float chestDepth;

    /**
     * 坐高
     */
    @Column
    @Description("坐高")
    public Float sittingHeight;
    /**
     * 大臂长
     */
    @Column
    @Description("大臂长")
    public Float uarmLength;

    /**
     * 小臂长
     */
    @Column
    @Description("小臂长")
    public Float larmLength;

    /**
     * brunnstrom分级
     */
    @Column
    @Description("brunnstrom分级")
    public Integer brunnstromLevel;

    /**
     * 适用下肢患者，
     * 必填
     */
    @Description("大腿长390-490")
    @Column
    public Float thighLength;

    /**
     * 适用下肢患者，
     * 必填
     */
    @Description("小腿长330-440")
    @Column
    public Float legLength;

    /**
     * 适用下肢患者
     * 非必填
     */
    @Description("胯宽")
    @Column
    public Float hipWidth;

    /**
     * 创建患者的时候，需要选择此患者是上肢患者还是下肢患者，
     * 如果是上肢患者，只能匹配选择上肢设备，
     * 如果是下肢患者，只能匹配选择下肢设备，
     * @see RobotType
     */
    @Description("上下肢机器人类型")
    @Column
    public Integer robotType;

    @Description("上下肢机器人类型")
    @Transient
    public String robotTypeText;


    @Column(length = 20)
    @Description("创建时间")
    public String createTime;

    /*云管需要的数据*/
    @ApiModelProperty(value = "医院ID")
    private String hospitalId;

    @ApiModelProperty(value = "系统ID")
    private String hospitalSystemId;

    public String getIllnessSideText() {
        if (IllnessSideType.SideBoth.getEnValue().equals(this.illnessSide)){
            this.illnessSideText = IllnessSideType.SideBoth.getEnName();
        } else if (IllnessSideType.SideLeft.getEnValue().equals(this.illnessSide)){
            this.illnessSideText = IllnessSideType.SideLeft.getEnName();
        } else if (IllnessSideType.SideRight.getEnValue().equals(this.illnessSide)){
            this.illnessSideText = IllnessSideType.SideRight.getEnName();
        }
        return illnessSideText;
    }

    public String getRobotTypeText() {
        if (RobotType.UpperLimb.getEnValue().equals(this.robotType)){
            this.robotTypeText = RobotType.UpperLimb.getEnName();
        } else if (RobotType.LowerLimb.getEnValue().equals(this.robotType)){
            this.robotTypeText = RobotType.LowerLimb.getEnName();
        }
        return robotTypeText;
    }

    public String getIllnessCauseText() {
        if (IllnessCauseType.CerebralInfarction.getEnValue().equals(String.valueOf(this.illnessCause))){
            this.illnessCauseText = IllnessCauseType.CerebralInfarction.getEnName();
        } else if (IllnessCauseType.CerebralHemorrhage.getEnValue().equals(String.valueOf(this.illnessCause))){
            this.illnessCauseText = IllnessCauseType.CerebralHemorrhage.getEnName();
        } else if (IllnessCauseType.Postoperative.getEnValue().equals(String.valueOf(this.illnessCause))){
            this.illnessCauseText = IllnessCauseType.Postoperative.getEnName();
        } else if (IllnessCauseType.Trauma.getEnValue().equals(String.valueOf(this.illnessCause))){
            this.illnessCauseText = IllnessCauseType.Trauma.getEnName();
        } else if (IllnessCauseType.Other.getEnValue().equals(String.valueOf(this.illnessCause))){
            this.illnessCauseText = IllnessCauseType.Other.getEnName();
        }
        return illnessCauseText;
    }

    public String getIllnessStageText() {
        if (IllnessStageType.MuscleTensionPeriod.getEnValue().equals(String.valueOf(this.illnessStage))){
            this.illnessStageText = IllnessStageType.MuscleTensionPeriod.getEnName();
        } else if (IllnessStageType.Convalescence.getEnValue().equals(String.valueOf(this.illnessStage))){
            this.illnessStageText = IllnessStageType.Convalescence.getEnName();
        } else if (IllnessStageType.Sequelae.getEnValue().equals(String.valueOf(this.illnessStage))){
            this.illnessStageText = IllnessStageType.Sequelae.getEnName();
        } else if (IllnessStageType.AcuteStage.getEnValue().equals(String.valueOf(this.illnessStage))){
            this.illnessStageText = IllnessStageType.AcuteStage.getEnName();
        }
        return illnessStageText;
    }
}